package com.woniu.controller;
import com.woniu.entity.RawMaterial;
import com.woniu.service.RawMaterialService;
import com.woniu.util.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
@RestController
@RequestMapping("/rm")
public class RawMaterialController {
    @Resource
    private RawMaterialService service;

    @GetMapping
    public ResponseUtil findAll(){ return service.findAll(); }
    @GetMapping("/a")
    public ResponseUtil findOne(){ return service.findOne(); }
    @GetMapping("/b")
    public ResponseUtil findTwo(){ return service.findTwo(); }

    @GetMapping("/{materialId}")
    public ResponseUtil findByMaterialIdId(@PathVariable Integer materialId){
        return service.findByMaterialId(materialId);
    }

    @GetMapping("/condition")
    public ResponseUtil findByCondition(RawMaterial rawMaterial) {
        return service.findByCondition(rawMaterial);
    }
    @GetMapping("/condition1")
    public ResponseUtil findByCondition1(RawMaterial rawMaterial) {
        return service.findByCondition1(rawMaterial);
    }

    @GetMapping("/condition2")
    public ResponseUtil findByCondition2(RawMaterial rawMaterial) {
        return service.findByCondition2(rawMaterial);
    }

    @PostMapping
    public ResponseUtil add(@RequestBody RawMaterial rawMaterial){ return service.add(rawMaterial); }

    @DeleteMapping("/{materialId}")
    public ResponseUtil delete(@PathVariable Integer materialId){ return service.delete(materialId); }

    @PutMapping
    public ResponseUtil update(@RequestBody RawMaterial rawMaterial){ return service.update(rawMaterial); }


    @PutMapping("/c")
    public ResponseUtil update1(@RequestBody RawMaterial rawMaterial){
        Integer materialId = rawMaterial.getMaterialId();
        Integer status = rawMaterial.getStatus();
        return service.update1(materialId,status);
    }
    @GetMapping("/stu")
    public ResponseUtil findByStatus(){ return service.findByStatus(); }
}
